﻿#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
//求n的阶乘
//int Fact(int n)
//{
//	if (n == 0)
//		return 1;
//	else
//		return n * Fact(n - 1);
//}
//int main()
//{
//	int n = 0;
//	scanf("%d", &n);
//
//	int ret = Fact(n);
//	printf("%d\n", ret);
//	return 0;
//}

int main()
{
	int a = 3;//正整数原反补相同
	//原码：00000000000000000000000000000011
	//反码：00000000000000000000000000000011
	//补码：00000000000000000000000000000011
	int b = -2;
	//原码：10000000000000000000000000000010
	//反码：11111111111111111111111111111101  //符号位不变，其他位取反
	//补码：11111111111111111111111111111110  //反码+1

	//左移操作符
	//左边抛弃，右边补0
	int b1 = b << 1;
	//原码：10000000000000000000000000000010
	//左移：00000000000000000000000000000100 ---4


	//右移操作符
	//左边⽤原该值的符号位填充，右边丢弃
	int a1 = a >> 1;
	//原码：00000000000000000000000000000011
	//右移：00000000000000000000000000000001 ---1

	printf("a=%d\n", a);//3
	printf("b=%d\n", b);//-2
	printf("b1=%d\n", b1);//4
	printf("a1=%d\n", a1);//1
	return 0;
}
